package com.ctshk.task.worker.processors;

import com.ctshk.rpc.hotel.service.IHotelH5Service;
import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult;
import com.github.kfcfans.powerjob.worker.core.processor.TaskContext;
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
import com.github.kfcfans.powerjob.worker.log.OmsLogger;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * @description 删除C端酒店Redis和es缓存
 * @author 谢诗宏
 * @date 2021/6/30
 */
@Slf4j
@Component
public class DeleteCacheHotelProcessor implements BasicProcessor {

    @DubboReference
    private IHotelH5Service hotelH5Service;

    @Override
    public ProcessResult process(TaskContext context) throws Exception {
        log.info("删除C端酒店Redis和es缓存");
        OmsLogger omsLogger = context.getOmsLogger();
        hotelH5Service.cacheUpdate(0);
        // 根据控制台参数判断是否成功
        boolean success = !"failed".equals(context.getJobParams());
        omsLogger.info("OrderEsProcessor finished process,success: .", success);

        return new ProcessResult(success, context + ": " + success);
    }
}
